import { Component, Input, Output, EventEmitter } from '@angular/core';
import type { TodoItem } from '../index';

@Component({
  selector: 'app-todo-item',
  templateUrl: './todo-item.component.html',
  styleUrls: ['./todo-item.component.css'],
})
export class TodoItemComponent {
  @Input() public item = {} as TodoItem;
  @Input() public index: number = 0;
  @Output() public removeTodoEvent = new EventEmitter<number>();
  @Output() public todoCheckStatusChangeEvent = new EventEmitter<void>();

  constructor() {}

  public removeTodo() {
    console.log(this.index);
    this.removeTodoEvent.emit(this.index);
  }
  public todoCheckStatusChange() {
    this.item.isCheck = !this.item.isCheck;
    this.todoCheckStatusChangeEvent.emit();
  }
}
